'use strict';

angular.module('app')
	.controller('sceneRouteController', [ '$rootScope', '$scope', '$http', '$state',
	                                function($rootScope, $scope, $http, $state) {
		$scope.title = '路线管理';
        $scope.param = { };
        $scope.loading = false;
        
		$scope.search = function () {
	        $scope.loading = true;
			$.ajax({
				url : $scope.app.project_name + '/route/read/list',
				data: $scope.param
			}).then(function(result) {
		        $scope.loading = false;
				if (result.httpCode == 200) {
					$scope.pageInfo = result.data;
				} else {
					$scope.msg = result.msg;
				}
				$scope.$apply();
			});
		}
		
		$scope.search();
		//重置按钮的操作
		$scope.clearSearch = function() {
			$scope.param.keyword= null;
            $scope.param={};//将输入的数据清空
			$scope.search();
		}
		
		$scope.delRoute = function(id) {
			$scope.alertModel({
				text:'确定删除？',
				btnCancel:true,
				resCode:"10000"
			}).then(function(){
				$.ajax({
					url : $scope.app.project_name + '/route/delete',
					data: {'id': id}
				}).then(function(result) {
			        $scope.loading = false;
					if (result.httpCode == 200) {
						$scope.alertModel({
							text:'删除成功',
							resCode:"10000"
						})
						$scope.param.keyword= null;
						$scope.search();
					} else {
						$scope.alertModel({
							text: result.msg,
							resCode:"10000"
						})
					}
				});
			})
			

		}
		
		// 翻页
        $scope.pagination = function (page) {
            $scope.param.pageNum=page;
            $scope.search();
        };
       
} ]);